package com.coderman.util;

import com.alibaba.fastjson.JSON;
import com.coderman.dto.ResponseDto;
import com.coderman.enums.ErrCodelEnum;

public class JsonResult {


	//封装返回不带说明的业务包
	public static String parseRqtMsg(int errCode){
		ResponseDto dto = new ResponseDto();
		dto.setCode(errCode);
		dto.setCodeMsg(ErrCodelEnum.getDescByCode(errCode));
		dto.setData("");
		if(dto.getRandomcode()==null){
			dto.setRandomcode(System.currentTimeMillis()+"");
		}  
		String msg = JSON.toJSONString(dto);
		return msg;
	}
	
	public static String parseRqtMsg2(int errCode){
		ResponseDto dto = new ResponseDto();
		dto.setCode(errCode);
		dto.setCodeMsg(ErrCodelEnum.getDescByCode(errCode));
		dto.setData("");
		if(dto.getRandomcode()==null){
			dto.setRandomcode(System.currentTimeMillis()+"");
		}
		String msg = JSON.toJSONString(dto);
		return msg;
	}
	//封装返回带说明的业务包
	public static String parseRqtMsg(int errCode, Object object){			
		ResponseDto dto = new ResponseDto();
		dto.setCode(errCode);
		dto.setCodeMsg(ErrCodelEnum.getDescByCode(errCode));
		
		dto.setData(object);
		dto.setRandomcode(System.currentTimeMillis()+"");
		
//		String msg = GsonUtil.toJson(dto);
		String msg = JSON.toJSONString(dto);
		return msg;
	}
}
